package com.carl.zlds.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.carl.zlds.model.GameTagInfo;
import com.carl.zlds.pojo.vo.GameTagInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author carl
 */
public interface GameTagInfoMapper extends BaseMapper<GameTagInfo> {
    @Update("update game_tag_info set weight = -1 where parent_id = #{parentId} and weight = 0")
    void deleteByParentId(@Param("parentId") Long parentId);

    @Select("<script> " +
            " select gti.*, gt.name as gameTagName from game_tag_info gti, game_tag gt where gti.weight >= 0 " +
            " and gti.game_tag_id = gt.id and gti.id in \n" +
            " <foreach collection=\"idList\" item=\"id\" open=\"(\" separator=\",\" close=\")\">\n" +
            "     #{id}\n" +
            " </foreach>" +
            "</script>")
    List<GameTagInfoVO> getGameTagInfoListByIdList(@Param("idList") List<Long> idList);
}
